<template>
  <div class="project-template-preview-dialog">
    <ProjectTemplatePreviewSimple 
      :project-data="projectData"
      @update-project="handleUpdateProject"
      @generate-word="handleGenerateWord"
    />

    <div class="dialog-footer">
      <el-button @click="handleClose">关闭</el-button>
      <!-- <el-button type="primary" @click="handleConfig">
        <el-icon><Setting /></el-icon>
        配置项目
      </el-button> -->
    </div>
  </div>
</template>

<script setup>
import { Setting } from '@element-plus/icons-vue'
import ProjectTemplatePreviewSimple from '../ProjectTemplatePreviewSimple.vue'

const props = defineProps({
  projectData: {
    type: Object,
    default: () => ({})
  }
})

const emit = defineEmits(['close'])

const handleClose = () => {
  emit('close')
}

const handleConfig = () => {
  // 通过 close 事件传递配置项目的标识
  emit('close', 'config', props.projectData)
}

const handleUpdateProject = (projectData) => {
  emit('close', 'config', projectData)
}

const handleGenerateWord = (projectData) => {
  emit('close', 'generate', projectData)
}
</script>

<style lang="scss" scoped>
.project-template-preview-dialog {
  .dialog-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ebeef5;
  }
}
</style>